package com.example.works;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;

public class Work05RadioButton extends AppCompatActivity implements View.OnClickListener {

    private RadioGroup rg_season;
    private TextView tv_result;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_work05_radio_button);
        //tv_result = findViewById(R.id.tv_result);
        rg_season = findViewById(R.id.rg_season);
        rg_season.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int id) {
                switch (id){
                    case R.id.rb_spring:
                        //tv_result.setText("你选择的是春天");
                        Toast.makeText(Work05RadioButton.this,"你选择的是春天",Toast.LENGTH_SHORT).show();
                        break;
                    case R.id.rb_summer:
                        //tv_result.setText("你选择的是夏天");
                        Toast.makeText(Work05RadioButton.this,"你选择的是夏天",Toast.LENGTH_SHORT).show();

                        break;
                    case R.id.rb_fall:
                        //tv_result.setText("你选择的是秋天");
                        Toast.makeText(Work05RadioButton.this,"你选择的是秋天",Toast.LENGTH_SHORT).show();

                        break;
                    case R.id.rb_winter:
                        //tv_result.setText("你选择的是冬天");
                        Toast.makeText(Work05RadioButton.this,"你选择的是冬天",Toast.LENGTH_SHORT).show();

                        break;
                    default:
                        break;
                }
            }
        });
    }

    @Override
    public void onClick(View view) {

    }
}